package test2;

public class Tunnel {
    private int peoplePassed = 0;//通过了0个人
    public synchronized void passThrough(String personName){
        try {
            Thread.sleep(5000);
            peoplePassed++;
            System.out.println(personName+"通过山洞，顺序："+peoplePassed);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
